// copyright 1993 Michael B. Johnson; some portions copyright 1994, MIT
// see COPYRIGHT for reuse legalities
//


#import "WWBezierSurfaceOfRevolution.h"

@implementation WWBezierSurfaceOfRevolution

- (BOOL)hasBoundingBox { return YES; }

- deriveHowManyPoints:(char *)archiveStr ofLength:(int)divisor
{
  char howManyStr[32];


  // the string looks like "[1234f]"
  strcpy(howManyStr, (archiveStr + 1));
  howManyStr[strlen(howManyStr) - 2] = '\0';
  howManyPoints = atoi(howManyStr) / divisor;

  return self;
}


- calculateBoundingBoxStartingAt:(RtFloat)shutterOpenTime endingAt:(RtFloat)shutterCloseTime 
{
  dirtyBoundingBox = FALSE; 
  return self;
}


- setBoundingBox:(RtBound *)newBoundingBox
{
  N3D_CopyBound(*newBoundingBox, boundingBox);

  return self;
}

- (RtBound *)boundingBox 
{ 
   if (dirtyBoundingBox) 
   {  [self calculateBoundingBoxStartingAt:[[myShape sceneClock] timestamp] endingAt:[[myShape sceneClock] timestamp]];
   }
   return &boundingBox; 
}

- setMyShape:shape { myShape = shape;  return self; }

- shape { return myShape; }

- recordSelf:(WW3DCamera *)camera;
{
  RiArchiveRecord("comment", "WWBezierSurfaceOfRevolution called to recordSelf:"); 
  return self;
}

- renderSelf:(WW3DCamera *)camera 
{
  RiBasis(RiBezierBasis, RI_BEZIERSTEP, RiBezierBasis, RI_BEZIERSTEP);
  RiPatchMesh(RI_BICUBIC, bezierWidth, RI_PERIODIC, nPoints, RI_NONPERIODIC, RI_P, (RtPointer)patchMesh, RI_NULL);
  return self;
}

- preRenderSelf:(WW3DCamera *)camera 
{
  return self;
}

- transformCTM:(RtMatrix)aMatrix { return self; }

- (BOOL)isMotionBlurrable { return NO; }


@end
